<?xml version="1.0" encoding="UTF-8" ?>
<%@ page import="org.swimv2.model.Abilita" %>
<%@ page import="java.util.Collection" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>

<script language="javascript">
function addInput(divName){
 	
	  var newdiv = document.createElement('div');
      newdiv.innerHTML = "<br>nuova abilità: " + "&nbsp; <input type='text' name='abSupp' id='abSupp'>" + "<div id='button'><input type='button' name='eliAb' id='submit' value='elimina' onclick='deleteNewElement(this)'/></div>";
      document.getElementById(divName).appendChild(newdiv);
   
}

function deleteElement(n){
	n.parentNode.parentNode.parentNode.parentNode.removeChild(n.parentNode.parentNode.parentNode);
}
	
function deleteNewElement(n){
	n.parentNode.parentNode.parentNode.removeChild(n.parentNode.parentNode);
}	



</script> 

<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>Gestione abilità</title>
<link rel="stylesheet" type="text/css" href="scheletro.css">
</head>
<body>
<div id="container">
<table class="topHome">
	<tr>
		    <td id="logoHome">
	<a href="home.jsp">Swim v2</a>
	<br><br><b> A help with a click!</b>
	
	
		    </td>
			<td class="personal">
				<br>
				<b>Ciao: <a href="paginaAmministratore.jsp">${sessionScope.utente.nome}</a> </b>&nbsp;&nbsp;&nbsp;<a href="NotificheAbServlet"><b>Notifiche</b></a>&nbsp;&nbsp;<a href="messaggi.jsp"><b>Messaggi</b></a>&nbsp;&nbsp;<a href="GestioneAbServlet"><b>Modifica abilità</b></a>
				&nbsp;&nbsp;<div id="button"><a href="Logout" id="logout">Logout</a></div>

			</td>			
	</tr>
</table>

<%
		@SuppressWarnings("unchecked")
		Collection <String> listAb = (Collection<String>) request.getAttribute("listAb");
%>

<br>
<%String messaggio1 = (String) request.getAttribute("message1");
String messaggio2 = (String) request.getAttribute("message2");
	if(messaggio1 != null) {
				out.println("<p class='logoutMessage'>" + messaggio1 + "</p>");
		} 
	if(messaggio2 != null) {
		out.println("<p class='errorMessage'>" + messaggio2 + "</p>");
} 	
%>

<br>

	  <div id="form">
	   	<div id="titlePage"><h1>Gestione abilità</h1></div>	<br><br>
					
					<fieldset>        
	        		<legend>Elenco abilità inserite: </legend>
	        			
	        			<ul>
	        				<%for(String a:listAb) {%>
	        				<li><form action="EliminaAb" method="post"><% out.print(a);%>&nbsp;&nbsp;
	        				<input type="hidden"  name="ab" id="ab" value="<%out.print(a); %>"/>
	        				<input type="submit" name="eliAb" id="button" value="elimina"> </form><br><br></li>
	        				<%} %>
	        			</ul>
	        		</fieldset><br><br>
	<form action="GestioneAbServlet" method="post">        
	     <div id="addAb">
	                <b>Abilità aggiuntive:</b> <br><br>
	                Vuoi aggiungere altre abilità? :
	                
	                <div id="button"><input type="button" name="addAb" id="submit" value="+" onclick="addInput('addAb');"/></div> <br><br>
	     </div>        	
	            	<br><br><br><br>	
	                <input type="submit" name="submit" id="button" value="Aggiungi" />
	</form>             
	  </div>




</div>
</body>
</html>